/*
 * @Description: 借阅 - 接收相关接口
 * @Author: Rfan
 * @Date: 2022-11-23 11:27:41
 * @LastEditTime: 2022-11-24 16:52:48
 */

import request from '@/utils/request';
import { Key } from 'react';
import { IPageQuery } from '@/interfaces/global';
import { IAddPlanParams } from '@/api/standardizedDetection/detectionPlan';

export interface IRegBorrowListParams {
  archiveTypeId?: number;
  archiveTypeName?: string;
  borrowPersonName?: string;
  borrowProcess?: number;
  borrowProcessTime?: string;
  borrowTime?: string;
  createTime?: string;
  deptName?: string;
  efileCount?: number;
  fileCount?: number;
  folderCount?: number;
  fondsId?: number;
  fondsName?: string;
  fondsNo?: string;
  id?: number;
  operator?: number;
  operatorName?: string;
  operatorTime?: string;
  registrant?: string;
  registrationTime?: string;
  remark?: string;
  unitName?: string;
  usePattern?: number;
  usePurpose?: string;
  userId?: number;
}

// 分页查询移交登记列表
export function fetchRegBorrowListByPage(data: IPageQuery<IRegBorrowListParams>) {
  return request({
    url: `/register-borrow/page`,
    method: 'post',
    data
  });
}

export interface IAddRegBorrowParams {
  archiveTypeId?: number;
  borrowPersonName?: string;
  borrowProcess?: number;
  borrowProcessTime?: string;
  borrowTime?: string;
  deptName?: string;
  efileCount?: number;
  fileCount?: number;
  folderCount?: number;
  fondsId?: number;
  registrant?: string;
  registrationTime?: string;
  remark?: string;
  unitName?: string;
  usePattern?: number;
  usePurpose?: string;
  userId?: number;
}

// 添加移交登记条目
export function addRegBorrow(data: IAddRegBorrowParams) {
  return request({
    url: `/register-receive`,
    method: 'post',
    data
  });
}

export interface IEditRegBorrowParams extends IAddRegBorrowParams {
  id: number;
}
// 编辑移交登记条目
export function editRegBorrow(data: IEditRegBorrowParams) {
  return request({
    url: `/register-borrow`,
    method: 'put',
    data
  });
}

// 删除移交登记条目
export function deleteRegBorrowItem(id: Key) {
  return request({
    url: `/register-borrow/${id}`,
    method: 'delete'
  });
}
